<!-- 企业信息查询 -->
<template>
  <div class="home-page-content">
    <h3 class="mb-20">经营信息预警查询</h3>
    <Form ref="formData" :model="formData" :label-width="80">
      <Row :gutter="30">
        <Col span="6">
          <FormItem label="公司名称" prop="companyName">
            <Input v-model="formData.companyName" placeholder="请输入"></Input>
          </FormItem>
        </Col>
        <Col span="6">
          <FormItem label="项目名称" prop="projectName">
            <Input v-model="formData.projectName" placeholder="请输入"></Input>
          </FormItem>
        </Col>
        <Col span="6">
          <FormItem label="产业标记" prop="industryNameList">
            <Select v-model="formData.industryNameList" placeholder="全部" clearable>
              <Option :value="it.name" v-for="(it, index) in industryAssignsList" :key="index">{{ it.name }}</Option>
            </Select>
          </FormItem>
        </Col>
      </Row>
      <Row :gutter="30">
        <Col span="6">
          <FormItem label="信息分类" prop="forewarningInfoClassify">
            <Select v-model="formData.forewarningInfoClassify" placeholder="全部" clearable>
              <Option value="NotReceiveForewarning">经营信息未接收预警</Option>
              <Option value="NotFeedbackForewarning">经营信息未反馈预警</Option>
            </Select>
          </FormItem>
        </Col>
        <Col span="6">
          <FormItem label="组织范围" prop="companyId">
            <OrganizationalTree v-model="formData.companyId" />
          </FormItem>
        </Col>

        <Col span="12" class="com-action-search-btn">
          <Button type="primary" icon="md-search" @click="handleSubmit('formData')">查询</Button>
          <BtnPlain type="primary" @click="handleReset('formData')">
            <Icon type="md-refresh" />
            <span>重置</span>
          </BtnPlain>
        </Col>
      </Row>
    </Form>
    <Table :columns="columns" :data="listData"></Table>
    <PageAtion
      v-if="formData.total"
      :total="formData.total"
      :size.sync="formData.size"
      :page.sync="formData.page"
      @pageSizeChange="pageSizeChange"
    />
  </div>
</template>

<script>
import ExpandTable from './expandTable'
import OrganizationalTree from '@/pages/components/organizationalTree'
import { getDictTreeByParentId } from '@/api/system.js'
import { busiInfoForewarningpPageList } from '@/api/businessInformationManage.js'

export default {
  name: 'businessInformationWarning',
  components: { ExpandTable, OrganizationalTree },
  data () {
    return {
      formData: {
        industryNameList: [],
        forewarningInfoClassify: '',
        companyName: '',
        projectName: '',
        companyId: '',
        page: 1,
        size: 10,
        total: 10,
      },
      columns: [
        {
          type: "expand",
          width: 50,
          render: (h, params) => {
            return h(ExpandTable, {
              props: {
                busInfoForewarningVoList: params.row.busInfoForewarningVoList,
              },
            });
          },
        },
        {
          title: '公司名称',
          key: 'companyName',
        },
        {
          title: '上级组织',
          key: 'parentName',
        },
        {
          title: '公司住所',
          key: 'companyAddress',
        },
        {
          title: '地区',
          key: 'city',
        },
        {
          title: '产业标记',
          key: 'industryName',
        },

      ],
      listData: [],
      industryAssignsList: []
    };
  },
  async created () {
    this.init()
    this.industryAssignsList = await getDictTreeByParentId({ parentId: 'COMPANY_SERVICE' })
  },
  methods: {
    async init () {
      const request = { ...this.formData }

      const { data, page, size, total } = await busiInfoForewarningpPageList(request)
      this.listData = data
      this.formData = { ...this.formData, ...{ page, size, total } }
    },
    handleReset (name) {
      this.$refs[name].resetFields();
      this.init()
    },
    handleSubmit (name) {
      this.formData.page = 1
      this.init()
    },
    pageSizeChange (row) {
      this.init()
    },
  },
};
</script>

<style lang="less" scoped>
.mb-20 {
  margin-bottom: 20px;
}
</style>
